package com.moli.iov.notify.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.notify.enums.StatusEnum;
import com.moli.iov.notify.mapper.NoticeVehicleCtlMapper;
import com.moli.iov.notify.model.dto.NoticeVehicleCtlDto;
import com.moli.iov.notify.model.po.NoticeVehicleCtl;
import com.moli.iov.notify.service.INoticeVehicleCtlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author wanghualin
 * @since 2019-10-08
 */
@Service
public class NoticeVehicleCtlServiceImpl extends ServiceImpl<NoticeVehicleCtlMapper, NoticeVehicleCtl> implements INoticeVehicleCtlService {


    @Autowired
    private NoticeVehicleCtlMapper noticeVehicleCtlMapper;

    public List<NoticeVehicleCtlDto> queryAllNoticeVehicleCtlByProperties(NoticeVehicleCtlDto noticeVehicleCtlDto){
        return noticeVehicleCtlMapper.queryAllNoticeVehicleCtlByProperties(noticeVehicleCtlDto);
    }

    public Boolean updateMailUsedAndSmsUsedById(NoticeVehicleCtlDto noticeVehicleCtlDto){
        return noticeVehicleCtlMapper.updateMailUsedAndSmsUsedById(noticeVehicleCtlDto);
    }

    public NoticeVehicleCtl queryNoticeVehicleCtlByProperties(Long companyId, Integer vehicleCtlCode){
        QueryWrapper<NoticeVehicleCtl> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(NoticeVehicleCtl::getCompanyId, companyId)
                .eq(NoticeVehicleCtl::getVehicleCtlCode, vehicleCtlCode)
                .eq(NoticeVehicleCtl::getIsDelete, StatusEnum.NO.getFlag());
        return this.getOne(queryWrapper);
    }

}
